import React, {Component} from "react";
import {Button, InputItem, Modal} from "antd-mobile-rn";

/**
 * 输入对话框
 */
export default class MInputDialog extends Component {

  constructor(props) {
    super(props);

    this.state = {
      password: '',
      visible: false,
    }
  }

  show = () => {
    this.setState({
      visible: true,
    });
  }

  onClose = () => {
    this.setState({
      visible: false,
    });
  }

  render() {
    const footerButtons = [
      {text: '确定', onPress: () => console.log('ok')},
    ];

    return (
      <Modal
        title="Title"
        transparent
        onClose={this.onClose}
        maskClosable
        footer={footerButtons}
        visible={this.state.visible}
        {...this.props}
      >
        <InputItem
          clear
          type={this.props.type}
          value={this.state.password}
          onChange={(value: any) => {
            this.setState({
              password: value,
            });
          }}
          placeholder={this.props.placeholder}
        >
          {this.props.tip}
        </InputItem>
      </Modal>
    );
  }
}